package cx.ath.skyflyer.gpslog.nmea;

import j2meunit.framework.*;

/**
 *
 * @author Ahti Legonkov
 */
public class NmeaSentenceTest extends TestCase {

    public NmeaSentenceTest() {
    }

    private NmeaSentenceTest(String name, TestMethod method) {
        super(name, method);
    }

    public void setUp() throws Exception {
        super.setUp();
    }

    public void tearDown() throws Exception {
        super.tearDown();
    }

    private void testChecksumMismatchException() {
        try {
            // checksum mismatch - actual checksum is 32.
            NmeaSentence n = new NmeaSentence("$GPVTG,0.00,T,,M,0.00,N,0.00,K,N*33");
            fail("ChecksumMismatchException expected");
        }
        catch (ChecksumMismatchException ex) {
        }
        catch (Exception ex) {
            fail("Wrong exception. ChecksumMismatchException expected");
        }
    }

    private void testNew() {
        try {
            NmeaSentence n = new NmeaSentence("$GPVTG,0.00,T,,M,0.00,N,0.00,K,N*32");
        }
        catch (Exception ex) {
            fail("Unexpected exception.");
        }
    }

    public Test suite() {
		TestSuite ts = new TestSuite();

        ts.addTest(new NmeaSentenceTest("testChecksumMismatchException", new TestMethod() {
            public void run(TestCase tc) {
                ((NmeaSentenceTest)tc).testChecksumMismatchException();
            }
        }));

        return ts;
    }
}
